package com.qf.smsplatform.strategy.util;


import com.qf.smsplatform.common.index.StandardReport;
import com.qf.smsplatform.common.index.StandardSubmit;
import com.qf.smsplatform.strategy.stream.PushSmsReportStream;
import com.qf.smsplatform.strategy.stream.SmsSendLogStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

@Component
public class PushMessageUtil {




    private  final int SEND_ERROR= 2;


    @Autowired
    private PushSmsReportStream pushSmsReportStream;

    @Autowired
    private SmsSendLogStream smsSendLogStream;


    //发送日志消息
    public  void  pushLog(StandardSubmit submit,String errorCode){
        //封装submit对象信息
        submit.setErrorCode(errorCode);

    //调用output方法，发送消息即可
        smsSendLogStream.output().send(MessageBuilder.withPayload(submit).build());
    }




    //发送推送报告消息
    public  void  pushReport(StandardSubmit submit,String errorCode){
        //封装StandReport
        StandardReport report = new StandardReport();
     report.setMobile(submit.getDestMobile());
     report.setClientID(submit.getClientID());
     report.setErrorCode(errorCode);
     report.setSrcID(submit.getSrcSequenceId());
     report.setState(SEND_ERROR);

        //调用output方法，发送消息即可
        pushSmsReportStream.output().send(MessageBuilder.withPayload(report).build());

    }

}
